const http = require("http");

const fs = require("fs");

// var config = require("./config").config;
const hostname = "127.0.0.1";
const port = 3000;

var server = http.createServer((request,response)=>{
    fs.readFile(__dirname+"/index.html","utf-8",function(error,data){
        // console.log(error);
        if(error){
            response.writeHead(404,{ "Content-Type":"text/plain;charset=utf-8" });
            // response.setHeader("Content-Type","text/plain");
            // response.statusCode = 404;
            response.end("NotFounded");
        }else{
            response.writeHead(200,{ "Content-Type":"text/html;charset=utf-8" });
            // response.setHeader("Content-Type","text/html");
            // response.statusCode = 200;
            response.end(data);
        }
    });
});

server.listen(port,hostname,function(){
    console.log(`server running at http://${hostname}:${port}`);
});